import math

def is_prime(num):
    if num == 1:
        return False
    if num == 2:
        return True
    for i in range(2,int(math.sqrt(num))+1):
        if num % i == 0:
            return False
        
    return True

def select_prime(ls):
    for i in ls:
        if is_prime(i):
            print(i,end=' ')

n = int(input())
ls = map(int,input().split())
select_prime(ls)